package vip.george.p1502;

import java.util.Arrays;

public class P1502 {
    public boolean canMakeArithmeticProgression(int[] arr) {
        //上来先进行排序
        Arrays.sort(arr);
        int diff = arr[1] - arr[0];
        for (int i = 1; i < arr.length -1; i++) {
            if (arr[i + 1] - arr[i] != diff) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        P1502 p = new P1502();
        System.out.println(p.canMakeArithmeticProgression(new int[]{3, 5, 1}));
        System.out.println(p.canMakeArithmeticProgression(new int[]{1, 2, 4}));
    }
}
